/*
 *  ME218_CLUT.h
 *  ArduinoOnXcode
 *
 *  Created by Rick Miley on 3/17/11.
 *  Copyright 2011 __MyCompanyName__. All rights reserved.
 *
 */



#ifndef ME218_CLUT_HEADER_FILE		// make sure CLUT header file is included only once
#define ME218_CLUT_HEADER_FILE

#include <avr/pgmspace.h>


// === Trying to suppress the warning messages. No luck ==========
// typedef PROGMEM struct CLUT_FLASH_data  CLUT_0_sequence;

//#ifdef PROGMEM 
//#undef PROGMEM
//#define PROGMEM __attribute__((__progmem__))
// #define PROGMEM __attribute__((__progmem__))

#define PROGMEM_XXX __attribute__((section(".progmem.miley")))
#define	prog_uchar_XXX unsigned char
#define	prog_uint16_t_XXX int  

//#endif

// typedef  prog_uint16_t  __attribute__((__progmem__)) i7t;
//extern prog_uint16_t  __attribute__((__progmem__)) i7t ;
// PROGMEM  i7t prognnnn = 7;



#define MAX_CC			15
#define	numCLUTs		32 
#define fixed_CLUT		-1



// Assign those colors names that we can use:
enum colors {
	Dark, Red, Orange, Yellow, Green, Blue, Violet, White, 
	DimRed,DimOrange,DimYellow,DimGreen,DimAqua,DimBlue,DimViolet,FullOn,
    CustomColor0, CustomColor1, CustomColor2, CustomColor3, CustomColor4,  
	CustomColor5, CustomColor6, CustomColor7, CustomColor8, CustomColor9
};     




// Predefined Colors: 
// Predefined Colors: 
#define MeggyDark      0,		0,		0
#define MeggyRed       15,		0,		0
#define MeggyOrange		15,		10,		0
#define MeggyYellow    3,		12,		0
#define MeggyGreen     0,		15,		0
#define MeggyBlue      0,		0,		15
#define MeggyViolet    12,		0,		12
#define MeggyWhite     8,		9,		9 

#define MeggyDimRed		2,		0,		0
#define MeggyDimGreen	0,		2,		0
#define MeggyDimBlue	0,		0,		2
#define MeggyDimOrange	15,		2,		0 
#define MeggyDimYellow	2,		2,		0
#define MeggyDimAqua	0,		6,		2
#define MeggyDimViolet	15,		0,		2
#define MeggyAllOn		15,		15,		15

#define MeggyNipple		1,		8,		8


// ============== LED data =================



struct  LED_FLASH_data {
	prog_uint16_t_XXX		pgm_LED_delay;
	prog_uchar_XXX		pgm_LED_0x01;
	prog_uchar_XXX		pgm_LED_0x02;
	prog_uchar_XXX		pgm_LED_0x04;
	prog_uchar_XXX		pgm_LED_0x08;
	prog_uchar_XXX		pgm_LED_0x10;
	prog_uchar_XXX		pgm_LED_0x20;
	prog_uchar_XXX		pgm_LED_0x40;
	prog_uchar_XXX		pgm_LED_0x80;
};

struct LED_Sprite_Sizes {
	LED_FLASH_data			*the_LED_sprite_array;
	prog_uint16_t_XXX		the_LED_sprite_len;
};

static prog_uchar_XXX LED_brightness_table[MAX_CC+1];
static	int		*SUPER_MAGIC_LED_VARIABLE;		// FIXME!!!

static int				LED_Table_delay;
static int				LED_Table_index;

static unsigned int		default_LED_brightness;

static unsigned int		live_LED;			// we parse the CLUT tables using this variable


static unsigned char				AuxLEDs;

// ============== CLUT data =================



struct CLUT_struct {
	int  live_red_value;
	int  live_green_value;
	int  live_blue_value;
};

struct  CLUT_FLASH_data {
	prog_uint16_t_XXX  cs_delay;
	prog_uint16_t_XXX  cs_red;
	prog_uint16_t_XXX  cs_green;
	prog_uint16_t_XXX  cs_blue;
};

struct CLUT_Sprite_Sizes {
	CLUT_FLASH_data		*the_sprite_array;
	prog_uint16_t_XXX		the_sprite_len;
};

static struct			CLUT_struct ColorTable[32];
static int				CLUT_mapper[128];
static int				ColorTable_delay[32];
static unsigned char	ColorTable_index[32];

static	int		*SUPER_MAGIC_CLUT_VARIABLE;		// FIXME!!!

static unsigned int		live_CLUT;			// we parse the CLUT tables using this variable

static unsigned char BRIGHT_LIGHT_0x80;
static unsigned char BRIGHT_LIGHT_0x40;
static unsigned char BRIGHT_LIGHT_0x20;
static unsigned char BRIGHT_LIGHT_0x10;
static unsigned char BRIGHT_LIGHT_0x08;
static unsigned char BRIGHT_LIGHT_0x04;
static unsigned char BRIGHT_LIGHT_0x02;
static unsigned char BRIGHT_LIGHT_0x01;

static int	GREMLIN;



#endif // CLUT header file



